'''
作者: 杨萍
介绍:实验管理-实验室预约审批模块重置接口测试
'''
import unittest
from jsonpath import jsonpath

from parameterized.parameterized import parameterized

from utils.reader import Reader
from utils.session import Session


class ResetTest(unittest.TestCase):
    """
    介绍:重置接口测试类
    作者:杨萍
    """
    session = None
    header = None

    @classmethod
    def setUpClass(cls) -> None:
        """
        测试类级别的脚手架方法，在测试类开始时执行，运行在此类测试方法调用之前
        """
        cls.session = Session.get_session()
        cls.header = Session.get_header()

    @classmethod
    def tearDownClass(cls) -> None:
        """
        测试类级别的脚手架方法，在测试类开始时执行，运行在此类测试方法调用之前
        """
        cls.session.close()

    @parameterized.expand(Reader.read_excel("reset_data.xlsx", min_row=1, max_row=6, min_col=1, max_col=2))
    def test_reset(self, searchExample, expected):
        """
        实验室预约审批模块 重置接口
        """
        url = "http://120.53.243.26:8009/api/laboratoryReserve/findPage"


        data = {"pageNumber": 0, "pageSize": 10, "pageOrder": [],
                      "searchDto":{"includeSea": "", "deptSysCodeSea": "", "deptCasCodeSea": "",
                                   "deptNameSea": "", "fromMenu": "", "searchExample": searchExample
                                   }
                      }

        # 发送请求
        resp = self.session.post(url, data=data, headers=self.header)

        # 断言状态码为200
        self.assertEqual(200, resp.status_code)

        # 根据响应提取出实际数据
        body = resp.json()

        # 实际响应中的resMsg,id
        real_resCode = jsonpath(body, "$..resCode")

        # 断言响应信息中的searchExample值为空字典时，resCode与预期值一致
        self.assertEqual(expected, real_resCode[0])









